
import pika_lvgl as lv
import PikaStdLib

mem = PikaStdLib.MemChecker()

btn_tnum = [1,2,3,4,5,6,7,8,9]

num1=0
num2=0
operator=0

def calculate(n1, n2, operator):
    '''
    :param n1: float
    :param n2: float
    :param operator: + - * /
    :return: float
    '''
    result = 0
    if operator == "+":
        result = n1 + n2
    if operator == "-":
        result = n1 - n2
    if operator == "*":
        result = n1 * n2
    if operator == "/":
        result = n1 / n2
    return result

arc = lv.obj(lv.scr_act())
arc.set_size(300, 400)
arc.center()

def resu():
    ta = lv.label(arc)
    ta.set_text(calculate())
    ta.align(lv.ALIGN.TOP_MID, 0, 10)

def event_cb_num1(evt):
    btn_tnum[0]


def event_cb_num2(evt):


def event_cb_num3(evt):


def event_cb_num4(evt):


def event_cb_num5(evt):


def event_cb_num6(evt):


def event_cb_num7(evt):


def event_cb_num8(evt):

def event_cb_num9(evt):

def event_cb_plus(evt):

def event_cb_miu(evt):

def event_cb_rid(evt):

def event_cb_equ(evt):

def event_cb_del(evt):

def event_cb_cle(evt):



btn1 = lv.btn(arc)
btn1.align(lv.ALIGN.CENTER,-100,-100)
label=lv.label(btn1)
label.set_text("1")
btn1.add_event_cb(event_cb_num1, lv.EVENT.CLICKED, 0)

btn2 = lv.btn(arc)
btn2.align(lv.ALIGN.CENTER,-50,-100)
btn2.set_height(lv.SIZE.CONTENT)
label=lv.label(btn2)
label.set_text("2")
label.center()
btn2.add_event_cb(event_cb_num2, lv.EVENT.CLICKED, 0)

btn3 = lv.btn(arc)
btn3.align(lv.ALIGN.CENTER,0,-100)
btn3.set_height(lv.SIZE.CONTENT)
label=lv.label(btn3)
label.set_text("3")
label.center()
btn3.add_event_cb(event_cb_num3, lv.EVENT.CLICKED, 0)

btnPlus = lv.btn(arc)
btnPlus.align(lv.ALIGN.CENTER,50,-100)
btnPlus.set_height(lv.SIZE.CONTENT)
label=lv.label(btnPlus)
label.set_text("+")
label.center()
btnPlus.add_event_cb(event_cb_plus, lv.EVENT.CLICKED, 0)


btn4 = lv.btn(arc)
btn4.align(lv.ALIGN.CENTER,-100,-50)
label=lv.label(btn4)
label.set_text("4")
btn4.add_event_cb(event_cb_num4, lv.EVENT.CLICKED, 0)


btn5 = lv.btn(arc)
btn5.align(lv.ALIGN.CENTER,-50,-50)
btn5.set_height(lv.SIZE.CONTENT)
label=lv.label(btn5)
label.set_text("5")
label.center()
btn5.add_event_cb(event_cb_num5, lv.EVENT.CLICKED, 0)

btn6 = lv.btn(arc)
btn6.align(lv.ALIGN.CENTER,0,-50)
btn6.set_height(lv.SIZE.CONTENT)
label=lv.label(btn6)
label.set_text("6")
label.center()
btn6.add_event_cb(event_cb_num6, lv.EVENT.CLICKED, 0)

btnMiu = lv.btn(arc)

btnMiu.align(lv.ALIGN.CENTER,50,-50)
btnMiu.set_height(lv.SIZE.CONTENT)

label=lv.label(btnMiu)
label.set_text("-")
label.center()


btn7 = lv.btn(arc)

btn7.align(lv.ALIGN.CENTER,-100,0)
label=lv.label(btn7)
label.set_text("7")

btn8 = lv.btn(arc)

btn8.align(lv.ALIGN.CENTER,-50,0)
btn8.set_height(lv.SIZE.CONTENT)

label=lv.label(btn8)
label.set_text("8")
label.center()

btn9 = lv.btn(arc)

btn9.align(lv.ALIGN.CENTER,0,0)
btn9.set_height(lv.SIZE.CONTENT)

label=lv.label(btn9)
label.set_text("9")
label.center()

btnRid = lv.btn(arc)

btnRid.align(lv.ALIGN.CENTER,50,0)
btnRid.set_height(lv.SIZE.CONTENT)

label=lv.label(btnRid)
label.set_text("*")
label.center()

btnDel = lv.btn(arc)

btnDel.align(lv.ALIGN.CENTER,-100,50)
label=lv.label(btnDel)
label.set_text("/")

btn0 = lv.btn(arc)

btn0.align(lv.ALIGN.CENTER,-40,50)
btn0.set_height(lv.SIZE.CONTENT)

label=lv.label(btn0)
label.set_text("0")
label.center()

btnCle = lv.btn(arc)

btnCle.align(lv.ALIGN.CENTER,20,50)
btnCle.set_height(lv.SIZE.CONTENT)

label=lv.label(btnCle)
label.set_text("Clean")
label.center()

btnEqu = lv.btn(arc)

btnEqu.align(lv.ALIGN.CENTER,90,50)
btnEqu.set_height(lv.SIZE.CONTENT)

label=lv.label(btnEqu)
label.set_text("=")
label.center()

print('mem used max: %0.2f kB' % (mem.getMax()))
print('mem used now: %0.2f kB' % (mem.getNow()))